home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1996 September / Software of the Month Club 1996 September.iso / mac / Software Research Institute-SRI / Business / Alpha ƒ / Tcl / SystemCode / eudora.tcl < prev    next >
Encoding:
Text File  |  1996-01-07  |  19.8 KB  |  697 lines  |  [TEXT/ALFA]

  1. #     <nowrap>
  2. # Built for Eudora
  3.  
  4. # Class message: A message
  5. # Elements:
  6. #     field by name
  7. # Properties:
  8. #     body  string  -- the body of the message
  9. #     priority  integer  -- the priority
  10. #     label  integer  -- the index of the label
  11. #     status  unread/already read/replied/forwarded/redirected/not sendable/sendable/queued/sent/never sent  -- the message status
  12. #     sender  string  -- the sender as appearing in the message summary
  13. #     date  string  [r/o]  -- the date as appearing in the message summary
  14. #     subject  string  -- the subject as appearing in the message summary
  15. #     size  integer  [r/o]  -- the size of the message
  16. #     outgoing  boolean  [r/o]  -- is the message is outgoing?
  17. #     signature  none/standard/alternate  -- which signature the message should have
  18. #     QP  boolean  -- is Eudora allowed to encode text?
  19. #     return receipt  boolean  -- is a return receipt is requested?
  20. #     wrap  boolean  -- should the text be wrapped when sent?
  21. #     tab expansion  boolean  -- should tabs get expanded to spaces?
  22. #     keep copy  boolean  -- should a copy should be kept after message is sent?
  23. #     preserve macintosh info  boolean  -- should Macintosh information always be sent with attachments?
  24. #     attachment encoding  AppleDouble/AppleSingle/BinHex/uuencode  -- the type of encoding to use for attachments
  25. #     show all headers  boolean  -- should all headers be visible?
  26. #     transliteration table  integer  -- the resource id of the transliteration table
  27. #     will be fetched  boolean  -- will the message be [re]fetched on next check?
  28. #     will be deleted  boolean  -- will the message be deleted from server on next check?
  29.  
  30. proc mailMenu {} {}
  31. proc dummyMail {} {}
  32.  
  33. enableMenuItem install "Rudimentary Eudora Interface" off
  34.  
  35. proc showEudoraMenuProc {flag} {
  36.     global showEudoraMenu mailMenu
  37.     
  38.     if {$showEudoraMenu} {
  39.         insertMenu $mailMenu
  40.     } else {
  41.         removeMenu $mailMenu
  42.     }
  43. }
  44.  
  45. #===============================================================================
  46. newModeVar Mail tossOnQueue        1    1
  47. newModeVar Mail    switchOnQueue    1    1
  48. newModeVar Mail    immediateSend    0    1
  49. #===============================================================================
  50.  
  51.  
  52. proc checkMailPath {} {
  53.     global mailPath modifiedVars
  54.     return [checkRunning "Mail app:" "CSOm" mailPath]
  55. }
  56.  
  57. if {![info exists eudoraBoxes]} {
  58.     set eudoraBoxes {In Out}
  59. }
  60.  
  61. menu -n $mailMenu -p eudoraProc {
  62.     "<SbackgroundEudora"
  63.     "<Seudora"
  64.     "help"
  65.     "(-"
  66.     "/e<UnewMessage"
  67.     "cc"
  68.     "bcc"
  69.     "(-"
  70.     "/f<Usend"
  71.     "/g<Ureply"
  72.     "(-"
  73.     "updateMailboxLists"
  74.     {menu -n openMailbox -p mailBoxProc -m {}}
  75.     {menu -n transfer -p transferProc -m {}}
  76.     "/h<UmoveToTrash"
  77.     "(-"
  78.     {menu -n tellEudora -p eudoraProc {
  79.         "/i<UflushOutbox"
  80.         "/j<UcheckForMail"
  81.         "(-"
  82.         startNotifying
  83.         stopNotifying}}
  84.     {menu -n mailFlags -p mailFlagsProc {flushOnCheck alertOnIncoming}}
  85. }
  86. menu -n openMailbox -p mailBoxProc -m $eudoraBoxes
  87. menu -n transfer -p transferProc -m $eudoraBoxes
  88.  
  89. proc eudoraProc {menu item} {
  90.     global mailPath HOME
  91.     global mailMenu
  92.     switch $item {
  93.         "eudora"        {launch -f $mailPath}
  94.         "backgroundEudora"        {launch $mailPath}
  95.         "help"            {edit -r "$HOME:Help:Eudora"}
  96.         "cc"            {eudoraCc}
  97.         "bcc"            {eudoraBcc}
  98.         "newMessage"    {mailNewMsg}
  99.         "reply"            {mailReplymsg}
  100.         "send"            {checkMailPath; mailSendCreatedMsg}
  101.         "flushOutbox"    {checkMailPath; mailFlushOut}
  102.         "checkForMail"    {checkMailPath; mailCheck}
  103.         "startNotifying" "checkMailPath; startNotifying"
  104.         "stopNotifying"    "checkMailPath; stopNotifying"
  105.         "moveToTrash"    {mailTrashmsg}
  106.         default            $item
  107.     }
  108. }
  109.  
  110. if {![info exists mailflushOnCheck]} {set mailflushOnCheck 1}
  111. if {![info exists mailalertOnIncoming]} {set mailalertOnIncoming 1}
  112. markMenuItem mailFlags flushOnCheck $mailflushOnCheck
  113. markMenuItem mailFlags alertOnIncoming $mailalertOnIncoming
  114.  
  115.  
  116. proc mailFlagsProc {menu flag} {
  117.     global mail$flag modifiedVars
  118.     set mail$flag [expr 1 - [set mail$flag]]
  119.     lappend modifiedVars mail$flag
  120.     markMenuItem mailFlags $flag [set mail$flag]
  121. }
  122.  
  123.  
  124. proc mailBoxProc {menu item} {
  125.     global inboxMembers ALPHA eudoraBoxes modifiedVars
  126.     global tileLeft tileTop tileWidth tileHeight errorHeight
  127.  
  128.     killMailboxWindow
  129.  
  130.     checkMailPath
  131.     switchTo $ALPHA
  132.  
  133.     global trashedMsgs$item
  134.     set trashedMsgs$item {}
  135.     
  136.     set inboxMembers {}
  137.     set text {}
  138.     set ind 1
  139.     foreach msg [mailSenders $item] {
  140.         set from [mailAddr [lindex $msg 0]]
  141.         set tag {}
  142.         while {[lsearch $inboxMembers $from$tag] >= 0} {
  143.             if {![string length $tag]} {
  144.                 set tag { <2>}
  145.             } else {
  146.                 regexp {[0-9]+} $tag tag
  147.                 set tag " <[expr $tag + 1]>"
  148.             }
  149.         }
  150.         append text [format "%-40s : %s\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t░$item░$ind\r" "$from$tag" [lindex $msg 1]]
  151.         lappend inboxMembers $from$tag
  152.         incr ind
  153.     }
  154.     if {![string length $text]} {
  155.         alertnote "No messages in '$item'!"
  156.         return
  157.     }
  158.     
  159.     new -n "* MAILBOX '$item' *" -g $tileLeft $tileTop $tileWidth $errorHeight
  160.     global winModes
  161.     set name [lindex [winNames] 0]
  162.     changeMode [set winModes($name) Brws]
  163.  
  164.     insertText "(<cr> to go to message)\r-----\r$text"
  165.     
  166.     select [nextLineStart [nextLineStart 0]] [nextLineStart [nextLineStart [nextLineStart 0]]]
  167.     setWinInfo dirty 0
  168.     setWinInfo read-only 1
  169.     message ""
  170. }
  171.  
  172.  
  173. proc killMailboxWindow {} {
  174.     if {[set ind [lsearch [winNames] {*MAILBOX*}]] >= 0} {
  175.         set win [lindex [winNames] $ind]
  176.         bringToFront $win
  177.         killWindow
  178.     }
  179. }
  180.  
  181.  
  182. proc mailGotoMatch {} {
  183.     if {[regexp {░(.+)░([0-9]+)} [getText [lineStart [getPos]] [nextLineStart [getPos]]] dummy folder ind]} {
  184.         global trashedMsgs$folder
  185.         
  186.         set deleted 0
  187.         for {set i 1} {$i < $ind} {incr i} {
  188.             if {[lsearch [set trashedMsgs$folder] $i] >= 0} {
  189.                 incr deleted
  190.             }
  191.         }
  192.         mailOpen $folder [expr $ind - $deleted] $ind
  193.     }
  194. }
  195.  
  196.  
  197. proc mailAddr {name} {
  198.     if {![regexp {<(.*)>} $name dummy addr]} {
  199.         regexp {^[^ ]+} $name addr
  200.     }
  201.     return $addr
  202. }
  203.  
  204.  
  205. proc mailSenders {folder} {
  206.     set cnt [mailCountMsgs $folder]
  207.     set msgs {}
  208.     for {set i 1} {$i <= $cnt} {incr i} {
  209.         set subject {}
  210.         regexp {From: (.*)} [mailGetField from $folder $i] dummy from
  211.         regexp {Subject: (.*)} [mailGetField subject $folder $i] dummy subject
  212.         lappend msgs [list $from $subject]
  213.     }
  214.     return $msgs
  215. }    
  216.  
  217.  
  218. proc eudoraCc {} {
  219.     if {![catch {set res [search -s -f 1 -r 1 -i 1 {cc:.*} 0]}]} {
  220.         goto [lindex $res 0]
  221.         endOfLine
  222.     } else {
  223.         beginningOfBuffer
  224.         nextLine
  225.         insertText "Cc: \r"
  226.         backwardChar
  227.     }
  228. }
  229.  
  230.  
  231. proc eudoraBcc {} {
  232.     if {![catch {set res [search -s -f 1 -r 1 -i 1 {bcc:.*} 0]}]} {
  233.         goto [lindex $res 0]
  234.         endOfLine
  235.     } else {
  236.         beginningOfBuffer
  237.         nextLine
  238.         insertText "Bcc: \r"
  239.         backwardChar
  240.     }
  241. }
  242.  
  243.  
  244. proc mailFlushOut {} {
  245.     global MailmodeVars
  246.     message "Telling Eudora to flush messages╔"
  247.  
  248.     AEBuild 'CSOm' CSOm eCon eSen bool(╟01╚) eChk bool(╟00╚)
  249.     message ""
  250. }
  251.  
  252.  
  253. proc mailCheck {} {
  254.     global MailmodeVars mailflushOnCheck
  255.     message "Told Eudora to check for new mail╔"
  256.  
  257.     AEBuild 'CSOm' CSOm eCon eSen bool(╟0$mailflushOnCheck╚) eChk bool(╟01╚)
  258. }
  259.  
  260.  
  261. proc mailReplymsg {} {
  262.     global inboxMembers
  263.  
  264.     set prefix "> "
  265.     set res [search -s -f 1 -r 1 {^>==} 0]
  266.     set header [getText 0 [lindex $res 0]]
  267.     
  268.     set from [mailGetFrom]
  269.     if {![regexp {Subject: ([^\r]*)} $header dummy subject]} {set subject ""}
  270.     set body [getText [expr [lindex $res 1] + 1] [maxPos]]
  271.  
  272.     regsub -all "\r" $body "\r$prefix" body
  273.     mailNewMsg $from "Re: $subject" "\r$prefix$body\r"
  274. }
  275.  
  276. proc transferProc {menu item} {
  277.     doFolderMove $item
  278. }
  279.  
  280.  
  281. proc mailTrashmsg {} {
  282.     doFolderMove Trash
  283. }
  284.  
  285. proc doFolderMove {toFolder} {
  286.     # Is this a summary or msg window?
  287.     if {[regexp "MAILBOX" [lindex [winNames] 0]]} {
  288.         if {![regexp {░(.*)░([0-9]+)} [getText [getPos] [nextLineStart [getPos]]] dummy folder orig]} {
  289.             beep
  290.             return
  291.         }
  292.         if {$toFolder == $folder} return
  293.         global trashedMsgs$folder
  294.  
  295.         set deleted 0
  296.         for {set i 1} {$i < $orig} {incr i} {
  297.             if {[lsearch [set trashedMsgs$folder] $i] >= 0} {
  298.                 incr deleted
  299.             }
  300.         }
  301.         set number [expr $orig - $deleted]
  302.         set summary 1
  303.     } else {
  304.         set pos [lindex [search -f 1 -r 1 {^Msg} 0] 0]
  305.         set text [getText $pos [nextLineStart $pos]]
  306.         regexp {([0-9]+)" \(([0-9]+).*mailbox "([a-zA-Z]+)} $text dummy number orig folder
  307.         if {$toFolder == $folder} return
  308.         set summary 0
  309.  
  310.         global trashedMsgs$folder
  311.     }
  312.     
  313.     message "Moving msg $number ($orig) of folder '$folder' to '$toFolder'"
  314.     moveMsg $number $folder $toFolder
  315.     if {!$summary} killWindow
  316.  
  317.     lappend trashedMsgs$folder $orig
  318.     
  319.     # Find summary info and delete it
  320.     set win [lindex [winNames] 0]
  321.     if {[regexp "MAILBOX" $win]} {
  322.         setWinInfo read-only 0
  323.     
  324.         set inds [search -f 1 -r 1 "░$folder░$orig\$" 0]
  325.         set pos [lindex $inds 0]
  326.         deleteText [lineStart $pos] [nextLineStart $pos]
  327.     
  328.         setWinInfo dirty 0
  329.         setWinInfo read-only 1
  330.  
  331.         nextLine
  332.         upBrowse
  333.     }
  334. }
  335.  
  336.     
  337. proc mailGetFrom {} {
  338.     set res [search -s -f 1 -r 1 {>==} 0]
  339.     set header [getText 0 [lindex $res 0]]
  340.     if {[regexp {From: ([^\r]*)} $header dummy from]} {
  341.         return [mailAddr $from]
  342.     }
  343.     error "No from line"
  344. }
  345.  
  346.     
  347.  
  348. proc mailSendCreatedMsg {} {
  349.     global MailmodeVars
  350.     
  351.     set name [checkMailPath]
  352.     set res [search -s -f 1 -r 0 {>==text follows this line==<} 0]
  353.     set header [getText 0 [lindex $res 0]]
  354.     
  355.     if {![regexp {To: ([^\r]*)} $header dummy to]} {set to ""}
  356.     if {![regexp {Cc: ([^\r]*)} $header dummy cc]} {set cc ""}
  357.     if {![regexp {Subject: ([^\r]*)} $header dummy subject]} {set subject ""}
  358.  
  359.     set body [getText [expr [lindex $res 1] + 1] [maxPos]]
  360.     
  361.     mailCreateMsg
  362.     mailSetField to $to
  363.     mailSetField cc $cc
  364.     mailSetField subject $subject
  365.     mailSetField "" $body
  366.     
  367.     if {$MailmodeVars(tossOnQueue)} {
  368.         setWinInfo dirty 0
  369.         killWindow
  370.     }
  371.  
  372.     mailQueueLast
  373.  
  374.     if {$MailmodeVars(switchOnQueue)} {
  375.         switchTo $name
  376.     }
  377.  
  378.     if {$MailmodeVars(immediateSend)} {
  379.         mailFlushOut
  380.     } else {
  381.         message "Message queued╔"
  382.     }
  383. }
  384.  
  385.     
  386. proc mailNewMsg {{to ""} {subject ""} {body ""}} {
  387.     new -n "New Mail"
  388.     global winModes
  389.     set name [lindex [winNames] 0]
  390.     changeMode [set winModes($name) Mail]
  391.  
  392.     insertText "To: $to\rSubject: $subject\r>==text follows this line==<\r$body"
  393.     setWinInfo dirty 0
  394.     goto 0
  395.     centerRedraw
  396.     mailTab
  397. }
  398.  
  399.  
  400. proc mailTab {} {
  401.     global mailKeywords
  402.     if {[catch {search -s -f 1 -r 1 -i 1 "([join $mailKeywords {|}]|^>)" [getPos]} res]} {
  403.         insertText "\t"
  404.         return
  405.     }
  406.     if {[lookAt [lindex $res 0]] == ">"} {
  407.         select [nextLineStart [lindex $res 1]] [maxPos]
  408.     } else {
  409.         goto [expr [lindex $res 1] + 1]
  410.         endLineSelect
  411.     }
  412. }
  413. bind '\t'                         mailTab Mail
  414.  
  415.  
  416. proc mailOpen {folder i originalNum} {
  417.     global tileLeft tileTop tileHeight trashedMsgs$folder
  418.     
  419.     set from [mailGetField From $folder $i]
  420.     set to [mailGetField To $folder $i]
  421.     set subject [mailGetField Subject $folder $i]
  422.     set sender [mailGetField Sender $folder $i]
  423.     set cc [mailGetField cc $folder $i]
  424.     set contents [mailGetField "" $folder $i]
  425.     
  426. #===============================================================================
  427.     global tileHeight tileWidth tileTop tileLeft errorHeight errorDisp
  428.     set top $tileTop
  429.     set geo [getGeometry]
  430.     if {([lindex $geo 0] != $tileLeft) || ([lindex $geo 1] != $top) || ([lindex $geo 2] != $tileWidth) || ([lindex $geo 3] != $errorHeight) } {
  431.         moveWin $tileLeft $top
  432.         sizeWin $tileWidth $errorHeight
  433.     }
  434.     set mar 28
  435.     incr top [expr $errorHeight + $mar]
  436. #===============================================================================
  437.     new -n "MAIL" -g $tileLeft $top $tileWidth [expr $errorDisp - 5]
  438.  
  439.     global winModes
  440.     set name [lindex [winNames] 0]
  441.     changeMode [set winModes($name) Mail]
  442.  
  443.     set text {}
  444.     if {[string length $subject]} {append text "$subject\r"}
  445.     if {[string length $to]} {append text "$to\r"}
  446.     if {[string length $from]} {append text "$from\r"}
  447.     if {[string length $cc]} {append text "$cc\r"}
  448.     if {[string length $sender]} {append text "$sender\r"}
  449.     append text "Msg \"$i\" ($originalNum) of mailbox \"$folder\"     Reply     Trash\r"
  450.     insertText "${text}>===============================================================================
  451. $contents
  452. "
  453.     goto 0
  454.     goto [lindex [search -f 1 -r 1 {^Msg "} 0] 0]
  455.     set pos [getPos]
  456.     regexp -indices {([0-9]+).*mailbox "(.+)".*(Reply).*(Trash)} [getText $pos [nextLineStart $pos]] dummy num fold rep tra
  457.     colorSelectPos [expr $pos + [lindex $num 0]] [expr 1 + $pos + [lindex $num 1]] bold 12
  458.     colorSelectPos [expr $pos + [lindex $fold 0]] [expr 1 +$pos + [lindex $fold 1]] bold 12
  459.     hyperSelectPos [expr $pos + [lindex $rep 0]] [expr 1 +$pos + [lindex $rep 1]] "mailReplymsg"
  460.     hyperSelectPos [expr $pos + [lindex $tra 0]] [expr 1 +$pos + [lindex $tra 1]] "mailTrashmsg"
  461.  
  462.     goto 0
  463.     setWinInfo dirty 0
  464.     setWinInfo read-only 1
  465.     centerRedraw
  466. }
  467.  
  468. proc colorSelectPos {from to ind ind2} {
  469.     insertColorEscape $from $ind
  470.     insertColorEscape $to $ind2
  471. }
  472.  
  473. proc hyperSelectPos {from to text} {
  474.     if {$from == $to} {
  475.         beep
  476.         return
  477.     }
  478.     insertColorEscape $from 3
  479.     insertColorEscape $from 15 $text
  480.     insertColorEscape $to 12
  481.     insertColorEscape $to 0
  482. }
  483.  
  484. proc mailFixMenus {} {
  485.     global mailMenu
  486.     
  487.     set ins {}
  488.     set outs {}
  489.     
  490.     set cnt [mailCountMsgs in]
  491.     for {set i 1} {$i <= $cnt} {incr i} {
  492.         lappend ins [mailGetField from in $i]
  493.     }
  494.     menu -n in {}
  495.     foreach item $ins {
  496.         addMenuItem -l "" in $item
  497.     }
  498.     
  499.     set cnt [mailCountMsgs out]
  500.     for {set i 1} {$i <= $cnt} {incr i} {
  501.         lappend outs [mailGetField from out $i]
  502.     }
  503.     menu -n out {}
  504.     foreach item $outs {
  505.         addMenuItem -l "" out $item
  506.     }
  507. }
  508.  
  509.  
  510. # make message at end of mailbox "out" of mail folder ""
  511. proc mailCreateMsg {} {
  512.     AEBuild -r 'CSOm' core crel {insh} {insl{kobj:obj {form:name, want:type(euMB), seld:╥out╙, from:obj {form:name, want:type(euMF), seld:'TEXT'(), from:'null'()}}, kpos:end }} kocl {type(euMS)}
  513. }
  514.  
  515.  
  516. # Move msg w/ specified index between folders, including to Trash.
  517. proc moveMsg {msg infolder outfolder} {
  518.     AEBuild -r 'CSOm' core move {----} "obj \{form:indx, want:type(euMS), seld:$msg, from:obj \{form:name, want:type(euMB), seld:╥$infolder╙, from:obj \{form:name, want:type(euMF), seld:'TEXT'(), from:'null'()\}\}\}" {insh} "insl\{kobj:obj \{form:name, want:type(euMB), seld:╥$outfolder╙, from:obj \{form:name, want:type(euMF), seld:'TEXT'(), from:'null'()\}\}, kpos:end \}"
  519. }
  520.  
  521.  
  522. # set field "fld" of message 0 to "to"
  523. proc mailSetField {fld to} {
  524.     AEBuild -r 'CSOm' core setd {----} "obj \{form:name, want:type(euFd), seld:╥$fld╙, from:obj \{form:indx, want:type(euMS), seld:1, from:'null'()\}\}" data "╥$to╙"
  525. }
  526.  
  527. proc mailGetField {field folder msg} {
  528.     if {[catch {AEBuild -r 'CSOm' core getd {----} "obj \{form:name, want:type(euFd), seld:╥$field╙, from:obj \{form:indx, want:type(euMS), seld:$msg, from:obj {form:name, want:type(euMB), seld:╥$folder╙, from:obj {form:name, want:type(euMF), seld:'TEXT'(), from:'null'()}}\}\}" {rtyp{type:TEXT}}} text]} {
  529.         return ""
  530.     }
  531.     set from [string first "╥" $text]
  532.     set to [string first "╙" $text]
  533.     return [string range $text [expr $from + 1] [expr $to - 1]]
  534. }
  535.  
  536. # obj {want:type('prop'), from:obj {form:indx, want:type(euMS), seld:$msg, from:obj {form:name, want:type(euMB), seld:╥$folder╙, from:obj {form:name, want:type(euMF), seld:'TEXT'(), from:'null'()}}}, form:'prop', seld:type('euST')}
  537.  
  538. proc mailMsgStatus {folder msg} {
  539.     if {[catch {AEBuild -r 'CSOm' core getd {----} "obj \{want:type('prop'), from:obj \{form:indx, want:type(euMS), seld:$msg, from:obj \{form:name, want:type(euMB), seld:╥$folder╙, from:obj \{form:name, want:type(euMF), seld:'TEXT'(), from:'null'()\}\}\}, form:'prop', seld:type('euST')\}"} text]} {
  540.         return ""
  541.     }
  542.     set from [string first "╥" $text]
  543.     set to [string first "╙" $text]
  544.     return [string range $text [expr $from + 1] [expr $to - 1]]
  545. }
  546.  
  547. proc mailQueueLast {} {
  548.     AEBuild -r 'CSOm' CSOm eQue ---- {obj {form:indx, want:type(euMS), seld:1, from:'null'()}}
  549. }
  550.  
  551. # CSOm\eAtc{'----':obj {form:indx, want:type(euMS), seld:1, from:'null'()}, eDcl:[fss (╟486172643A4465736B746F7020466F6C6465723A62756773╚)]}
  552. proc mailAttachmentDoesntWork {name} {
  553.     AEBuild -r 'CSOm' CSOm eAtc ---- {obj {form:indx, want:type(euMS), seld:1, from:'null'()}} eDcl [makeAlis $name]
  554. }
  555.  
  556. # core\setd{'----':obj {form:prop, want:type(prop), seld:type(euPY), from:obj {form:indx, want:type(euMS), seld:1, from:'null'()}}, data:1}
  557. proc mailSetNumberProperty {prop to} {
  558.     AEBuild -r 'CSOm' core setd ---- "obj \{form:prop, want:type(prop), seld:type($prop), from:obj \{form:indx, want:type(euMS), seld:1, from:'null'()\}\}" data $to
  559. }    
  560.  
  561.  
  562. # obj {want:type('prop'), from:obj {form:indx, want:type(euMS), seld:$msg, from:obj {form:name, want:type(euMB), seld:╥$folder╙, from:obj {form:name, want:type(euMF), seld:'TEXT'(), from:'null'()}}}, form:'prop', seld:type('euST')}
  563. # Useful for: euPY, eBod, euSe, euSu, eCpy euPY
  564. proc mailGetNumberProperty {prop} {
  565.     AEBuild -r 'CSOm' core getd ---- "obj \{form:prop, want:type(prop), seld:type($prop), from:obj \{form:indx, want:type(euMS), seld:1, from:'null'()\}\}" 
  566. }
  567.  
  568. proc mailCountMsgs {mbox} {
  569.     set text [AEBuild -r 'CSOm' core cnte ---- "obj \{form:name, want:type(euMB), seld:╥$mbox╙, from:obj \{form:name, want:type(euMF), seld:'TEXT'(), from:'null'()\}\}" kocl {type(euMS)}]
  570.     if {[regexp {:([0-9]+)} $text dummy mtch]} {
  571.         return $mtch
  572.     }
  573.     error "Bad count"
  574. }
  575.  
  576. proc mailCountMailboxes {} {
  577.      set text [AEBuild -r 'CSOm' core cnte ---- "obj \{form:name, want:type(euMF), seld:'TEXT'(), from:'null'()\}" kocl {type(euMB)}]
  578.     if {[regexp {:([0-9]+)} $text dummy mtch]} {
  579.         return $mtch
  580.     }
  581.     error "Bad count"
  582. }
  583.  
  584. proc updateMailboxLists {} {
  585.     set num [mailCountMailboxes]
  586.     for {set i 1} {$i <= $num} {incr i} {
  587.         set res [AEBuild -r 'CSOm' core getd ---- "obj \{form:prop, want:type(prop), seld:type(euFS), from:obj \{form:indx, want:type(euMB), seld:$i, from:obj \{form:name, want:type(euMF), seld:'TEXT'(), from:'null'()\}\}\}" ]
  588.         if {[regexp {╟(.*)╚} $res dummy fss]} {
  589.             set name [file tail [specToPathName $fss]]
  590.             message $name
  591.             lappend boxes $name
  592.         }
  593.     }
  594.     
  595.     global eudoraBoxes modifiedVars
  596.     lappend modifiedVars eudoraBoxes
  597.     set eudoraBoxes $boxes
  598.     menu -n openMailbox -p mailBoxProc -m $eudoraBoxes
  599.     menu -n transfer -p transferProc -m $eudoraBoxes
  600.     message "done."
  601. }
  602.  
  603.  
  604. #===============================================================================
  605.  
  606. eventHandler CSOm eNot "eudoraHandler"
  607.  
  608. # a sample 'msgs': obj {want:type(euMS), from:obj {want:type(euMB), from:obj {want:type(euMF), from:'null'(), form:name, seld:'TEXT'()}, form:name, seld:╥In╙}, form:indx, seld:18}, obj {want:type(euMS), from:obj {want:type(euMB), from:obj {want:type(euMF), from:'null'(), form:name, seld:'TEXT'()}, form:name, seld:╥In╙}, form:indx, seld:19}
  609. proc eudoraHandler {it} {
  610.     global blah mailalertOnIncoming
  611.     message ""
  612.     if {[regexp {eWHp:wArv.*\[(obj.*)\], &repq} $it dum1 msgs]} {
  613.         set ids [getMsgIDs $msgs]
  614.         if {$mailalertOnIncoming} {
  615.             mailBrowser In $ids
  616.             beep; beep
  617.         }
  618.     }
  619. }
  620.  
  621.  
  622. proc mailBrowser {folder ids} {
  623.     global inboxMembers ALPHA
  624.     global tileLeft tileTop tileWidth tileHeight errorHeight
  625.  
  626.     checkMailPath
  627.     switchTo $ALPHA
  628.  
  629.     global trashedMsgs$folder
  630.     set trashedMsgs$folder {}
  631.     
  632.     set inboxMembers {}
  633.     set text {}
  634.  
  635.     foreach id $ids {
  636.         regexp {From: (.*)} [mailGetField from $folder $id] dummy from
  637.         set from [mailAddr $from]
  638.         set subject {}
  639.         regexp {Subject: (.*)} [mailGetField subject $folder $id] dummy subject
  640.         set tag {}
  641.         while {[lsearch $inboxMembers $from$tag] >= 0} {
  642.             if {![string length $tag]} {
  643.                 set tag { <2>}
  644.             } else {
  645.                 regexp {[0-9]+} $tag tag
  646.                 set tag " <[expr $tag + 1]>"
  647.             }
  648.         }
  649.         append text [format "%-40s : %s\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t░In░$id\r" "$from$tag" $subject]
  650.         lappend inboxMembers $from$tag
  651.     }
  652.     if {![string length $text]} {
  653.         alertnote "No messages!"
  654.         return
  655.     }
  656.     
  657.     if {[set ind [lsearch [winNames] "*Incoming MAILBOX*"]] >= 0} {
  658.         bringToFront [lindex [winNames] $ind]
  659.         setWinInfo read-only 0
  660.         endOfBuffer
  661.         insertText $text
  662.     } else {
  663.         killMailboxWindow
  664.         new -n "* Incoming MAILBOX *" -g $tileLeft $tileTop $tileWidth $errorHeight
  665.         global winModes
  666.         set name [lindex [winNames] 0]
  667.         changeMode [set winModes($name) Brws]
  668.     
  669.         insertText "(<cr> to go to message)\r-----\r$text"
  670.     }
  671.     select [nextLineStart [nextLineStart 0]] [nextLineStart [nextLineStart [nextLineStart 0]]]
  672.     setWinInfo dirty 0
  673.     setWinInfo read-only 1
  674.     message ""
  675. }
  676.  
  677.  
  678. proc getMsgIDs {text} {
  679.     if {[regexp -indices {seld:([0-9]+)} $text dummy ind]} {
  680.         return [concat [string range $text [lindex $ind 0] [lindex $ind 1]] [getMsgIDs [string range $text [lindex $ind 1] end]]]
  681.     }
  682. }
  683.  
  684. proc startNotifying {} {
  685.     global HOME ALPHA quitHooks
  686.     
  687.     AEBuild 'CSOm' CSOm nIns ---- [makeAlis "$HOME:$ALPHA"]
  688.     lappend quitHooks stopNotifying
  689. }
  690.  
  691. proc stopNotifying {} {
  692.     global HOME ALPHA
  693.     
  694.     AEBuild 'CSOm' CSOm nRem ---- [makeAlis "$HOME:$ALPHA"]
  695. }
  696.